<?php
//watermark program
//Show that a jpeg image is going to be returned
//echo $QUERY_STRING;
//exit;
header("Content-type: image/jpeg");

//File names
$wmark='watermark.png';
$mimage=$QUERY_STRING;
//'image01.jpg';




//Loading
$watermark_img = imagecreatefrompng($wmark); //(1)
imagecolortransparent($watermark_img,0);//(2)

$wmrk_size = getimagesize($wmark);//(3)
$main_img = imagecreatefromjpeg($mimage);//(4)

//Merge the 2 buffers//(5)
imagecopymerge($main_img,$watermark_img,0,0,0,0,
               $wmrk_size[0],$wmrk_size[1],100); 
//or
//imagecopy($main_img,$watermark_img,0,0,0,0,
//            $wmrk_size[0],$wmrk_size[1]);

//Output file to browser
imagejpeg($main_img);//(6)
imagedestroy($watermark_img);//(7)
imagedestroy($main_img);
?>
